package org.yx.service.sres.view_maintain_items_without_device;

import org.dbist.dml.Page;
import org.dbist.dml.Query;
import org.yx.models.SresMtnDef;
import org.yx.utils.BaseService;

import com.xiaoleilu.hutool.util.StrUtil;

/**
 * 查询所有的维护保养项，不含已配置在设备里的项
 * 
 * @author zxw
 * @since 2019/09/01
 **/
public class SresViewMaintainItemsWithoutDeviceService extends BaseService {
	public SresViewMaintainItemsWithoutDeviceOut viewMaintainItemsWithoutDevice(SresViewMaintainItemsWithoutDeviceIn in)
			throws Exception {
		Query query = new Query(in.getPageIndex(), in.getPageSize());
		query.addFilter("orgCode", in.getUserOrgCode());
		if (StrUtil.isNotBlank(in.getResId())) {
			query.addFilter("resId", in.getResId());
		}
		if (StrUtil.isNotBlank(in.getCond())) {
			query.addFilter("cond", "%" + in.getCond() + "%");
		}

		Page<SresMtnDef> mtnDefPage = selectPageBySqlFilePath("select_all_maintain_item.sql", query, SresMtnDef.class);

		SresViewMaintainItemsWithoutDeviceOut out = new SresViewMaintainItemsWithoutDeviceOut();
		out.setItemList(mtnDefPage.getList());
		out.setTotal(mtnDefPage.getTotalSize());

		return out;
	}
}